home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
earcd
/
misc
/
edu
/
ditodev.lha
/
DITOdev
/
FastDict
/
FastDict.c
next >
Wrap
C/C++ Source or Header
|
1996-12-26
|
23KB
|
885 lines
/*
* FastDict © Dirk Holtwick, 1996
*
*/
#define VERS "0.1 beta"
#define NAME "FastDict"
/// DEBUG
#define X printf("Zeile: %4d, Datei: '%s', Taste: ",__LINE__,__FILE__); gets(debugstr);
#ifndef X
#define X
#else
char debugstr[80];
#endif
///
/// Includes
#define DitoExtBase data->DitoExtBaseOO
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <exec/memory.h>
#include <prefs/prefhdr.h>
#include <datatypes/pictureclass.h>
#include <libraries/locale.h>
#include <libraries/asl.h>
#include <libraries/gadtools.h>
#include <libraries/mui.h>
#include <clib/exec_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/utility_protos.h>
#include <clib/dos_protos.h>
#include <clib/locale_protos.h>
#include <clib/muimaster_protos.h>
#include <clib/alib_protos.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/utility_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/locale_pragmas.h>
#include <pragmas/muimaster_pragmas.h>
#include <proto/dito.h>
#include <proto/ditoext.h>
///
/// Compiler Stuff
#ifdef _DCC
#define REG(x) __ ## x
#define ASM
#define SAVEDS __geta4
#else
#define REG(x) register __ ## x
#define ASM __asm
#define SAVEDS __saveds
#endif
///
/// Some Definitions
#define MUISERIALNR_STUNTZI 1
#define TAGBASE_STUNTZI (TAG_USER | ( MUISERIALNR_STUNTZI << 16))
#define MUIM_MainWindow_Finish (TAGBASE_STUNTZI | 0x1070)
#define MUIM_MainWindow_About (TAGBASE_STUNTZI | 0x1071)
#define MUIM_MainWindow_Open (TAGBASE_STUNTZI | 0x1073)
#define MUIM_MainWindow_Refresh (TAGBASE_STUNTZI | 0x1074)
#define MUIM_MainWindow_Grammar (TAGBASE_STUNTZI | 0x1075)
#define MUIM_MainWindow_Update (TAGBASE_STUNTZI | 0x1076)
#define MUIM_MainWindow_Iconify (TAGBASE_STUNTZI | 0x1077)
///
/// Global Vars
LONG __stack = 8192;
struct Library *DitoBase ;
struct Library *MUIMasterBase;
struct Library *GfxBase ;
struct Library *IntuitionBase;
struct Library *LocaleBase ;
struct Library *AslBase ;
struct Library *UtilityBase ;
Object *win;
extern struct Library *DOSBase;
struct DITO_UserInfo ui;
struct MUI_CustomClass *CL_MainWindow ;
#define TG CHECKIT|MENUTOGGLE
enum { MEN_OPEN=1,MEN_ABOUT,MEN_QUIT,MEN_HIDE,MEN_MUI };
struct NewMenu MainMenu[] =
{
{ NM_TITLE, (STRPTR)"Project" , 0 ,0,0,(APTR)0 },
{ NM_ITEM , (STRPTR)"Open" ,"O",0,0,(APTR)MEN_OPEN },
{ NM_ITEM , (STRPTR)NM_BARLABEL , 0 ,0,0,(APTR)0 },
{ NM_ITEM , (STRPTR)"About" ,"?",0,0,(APTR)MEN_ABOUT },
{ NM_ITEM , (STRPTR)NM_BARLABEL , 0 ,0,0,(APTR)0 },
{ NM_ITEM , (STRPTR)"Hide" ,"H",0,0,(APTR)MEN_HIDE },
{ NM_ITEM , (STRPTR)"Quit" ,"Q",0,0,(APTR)MEN_QUIT },
{ NM_TITLE, (STRPTR)"Config" , 0 ,0,0,(APTR)0 },
{ NM_ITEM , (STRPTR)"MUI" , 0 ,0,0,(APTR)MEN_MUI },
{ NM_END,NULL,0,0,0,(APTR)0 },
};
///
/// Misc Help Functions
LONG xget(Object *obj,ULONG attribute)
{
LONG x;
get(obj,attribute,&x);
return(x);
}
char *getstr(Object *obj)
{
return((char *)xget(obj,MUIA_String_Contents));
}
BOOL getbool(Object *obj)
{
return((BOOL)xget(obj,MUIA_Selected));
}
VOID setstr(APTR str,LONG num)
{
DoMethod(str,MUIM_SetAsString,MUIA_String_Contents,"%ld",num);
}
VOID settxt(APTR str,LONG num)
{
DoMethod(str,MUIM_SetAsString,MUIA_Text_Contents,"%ld",num);
}
ULONG __stdargs DoSuperNew(struct IClass *cl,Object *obj,ULONG tag1,...)
{
return(DoSuperMethod(cl,obj,OM_NEW,&tag1,NULL));
}
Object *MakeCheck(char *s)
{
Object *obj = MUI_MakeObject(MUIO_Checkmark,s);
if (obj) set(obj,MUIA_CycleChain,1);
return(obj);
}
Object *MakeButton(char *s)
{
Object *obj = MUI_MakeObject(MUIO_Button,s);
if (obj) set(obj,MUIA_CycleChain,1);
return(obj);
}
/*
Object *MakeBackground(int num)
{
Object *obj;
obj = MUI_NewObject(MUIC_Popimage,
MUIA_Imageadjust_Type, MUIV_Imageadjust_Type_Background,
MUIA_Window_Title, "Adjust Screen Background",
MUIA_CycleChain, 1,
TAG_DONE);
return(obj);
}
*/
Object *MakeString(int maxlen, char *s)
{
Object *obj = MUI_MakeObject(MUIO_String,s,maxlen);
if (obj)
{
SetAttrs(obj,
MUIA_CycleChain,1,
MUIA_String_AdvanceOnCR,TRUE,
TAG_DONE);
}
return(obj);
}
Object *MakeCycle(char **array,char *s)
{
Object *obj = MUI_MakeObject(MUIO_Cycle ,s,array);
if (obj) set(obj,MUIA_CycleChain,1);
return(obj);
}
Object *MakeSlider(int min,int max,char *s)
{
Object *obj = MUI_MakeObject(MUIO_Slider,s,min,max);
if (obj) set(obj,MUIA_CycleChain,1);
return(obj);
}
/*
static Object *MakeCLabel(int num) { return(MUI_MakeObject(MUIO_Label,GetStr(num),MUIO_Label_Centered)); }
Object *MakeLabel (int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),0)); }
Object *MakeLabel1 (int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_SingleFrame)); }
Object *MakeLabel2 (int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_DoubleFrame)); }
Object *MakeLLabel (int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_LeftAligned)); }
Object *MakeLLabel1 (int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_LeftAligned|MUIO_Label_SingleFrame)); }
Object *MakeFreeLabel(int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_FreeVert)); }
Object *MakeFreeLLabel(int num) { return(MUI_MakeObject(MUIO_Label ,GetStr(num),MUIO_Label_FreeVert|MUIO_Label_LeftAligned)); }
*/
///
// Mainwindow
/// struct MainWindow_Data
struct MainWindow_Data
{
struct DITO_Database *db;
struct DITO_Dict *dict;
struct DITO_OutputData *output;
struct Library *DitoExtBaseOO;
Object *str, *list, *balance, *grammar;
};
///
/// Display
SAVEDS ASM void Display (REG(a2) char **array, REG(a1) struct DITO_Entry *act)
{
*array++ = DITO_GetStr(act, DITO_Str_Word);
*array = DITO_GetStr(act, DITO_Str_Translation);
}
///
/// InitSearch
void InitSearch(struct MainWindow_Data *data)
{
DoMethod (data->list, MUIM_List_Clear);
if(data->db) DITO_InitDatabase(data->db);
}
///
/// DisposeExt
void DisposeExt(struct MainWindow_Data *data)
{
if(data->output)
{
DITO_DisposeOutput(data->output);
data->output = 0;
}
if(DitoExtBase)
{
CloseLibrary(DitoExtBase);
DitoExtBase = 0;
}
}
///
/// MainWindow_Iconify
ULONG MainWindow_Iconify(struct IClass *cl,Object *obj,struct Msg *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
set((Object *)xget(obj,MUIA_ApplicationObject),MUIA_Application_Iconified,TRUE);
return(0);
}
///
/// MainWindow_Finish
ULONG MainWindow_Finish(struct IClass *cl,Object *obj,struct Msg *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
// puts("MW_Finish");
/*
{
ULONG i;
DITO_LoadDictData (data->db, data->dict, "vaca", 0);
for(i=0;i<data->db->sum;i++)
{
puts(
DITO_GetStr( DITO_GetPtr(data->db, i), DITO_Str_Word)
);
}
}
*/
if(data->db) DITO_DisposeDatabase(data->db);
if(data->dict) DITO_CloseDict(data->dict);
DisposeExt(data);
DoMethod((Object *)xget(obj,MUIA_ApplicationObject),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
return(0);
}
///
/// MainWindow_Refresh
ULONG MainWindow_Refresh(struct IClass *cl,Object *obj,struct {ULONG MethodID; char *s;} *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
char *str;
if(msg->s)
{
set(data->str, MUIA_String_Contents, msg->s);
}
// else
{
set(data->str, MUIA_Disabled, TRUE);
set(app,MUIA_Application_Sleep,TRUE);
get(data->str, MUIA_String_Contents, &str);
set (data->list, MUIA_List_Quiet, TRUE);
InitSearch(data);
if(data->dict && *str)
{
DITO_LoadDictData (data->db, data->dict, str, DITO_Cmp_First);
if(data->db->sum)
{
DoMethod (
data->list,
MUIM_List_Insert,
data->db->arr.entries, // Table of found entries
data->db->sum, // Number of entries
MUIV_List_Insert_Bottom
);
}
}
set (data->list, MUIA_List_Quiet, FALSE);
set(app,MUIA_Application_Sleep,FALSE);
set (data->str, MUIA_Disabled, FALSE);
set (obj, MUIA_Window_ActiveObject, data->str);
}
return(0);
}
///
/// MainWindow_Grammar
ULONG MainWindow_Grammar(struct IClass *cl,Object *obj,struct Msg *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
struct DITO_Entry *v;
// Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
DoMethod (data->list, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &v);
if(v){
set(data->grammar, MUIA_Disabled, FALSE);
// if(!data->master){
DITO_WriteOutput (data->output, v);
DoMethod(obj, MUIM_MainWindow_Update, 0);
// }
}else{
set(data->grammar, MUIA_Disabled, TRUE);
}
return(0);
}
///
/// MainWindow_Update
ULONG MainWindow_Update(struct IClass *cl,Object *obj,struct Msg *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
struct DITO_Entry *v;
// if(!data->master){
// set(app,MUIA_Application_Sleep,TRUE);
DoMethod (data->list, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &v);
if(v){
DITO_UpdateOutput(data->output, v);
}
// get(listview, MUIA_Listview_ClickColumn, &col);
// set(app,MUIA_Application_Sleep,FALSE);
// }
return(0);
}
///
/// MainWindow_About
ULONG MainWindow_About(struct IClass *cl,Object *obj,Msg msg)
{
char userstr[200];
Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
static const char AboutText[] = "\33b\33c" NAME "\33n\n\33cVersion %s\n\33c%s\n\n\033c%s\n\n\33c\33i %s \33n\n\n\33cARexx-Port: %s";
// struct MainWindow_Data *data = INST_DATA(cl,obj);
if(ui.nr) sprintf(userstr,"Registered for %s, #%u",ui.name,ui.nr);
else strcpy(userstr,"!!! UNREGISTERED VERSION !!!");
MUI_Request(app,obj,0,NULL,"*_OK",(char *)AboutText,
((char *)xget(app,MUIA_Application_Version))+7+strlen(NAME),
((char *)xget(app,MUIA_Application_Copyright)),
userstr,
((char *)xget(app,MUIA_Application_Description)),
((char *)xget(app,MUIA_Application_Base)));
return(0);
}
///
/// IntuiMsgFunc
SAVEDS ASM VOID IntuiMsgFunc(REG(a1) struct IntuiMessage *imsg,REG(a2) struct FileRequester *req)
{
if (imsg->Class==IDCMP_REFRESHWINDOW)
DoMethod(req->fr_UserData,MUIM_Application_CheckRefresh);
}
///
/// getfilename
char *getfilename(char *title,BOOL save)
{
static char buf[512];
struct FileRequester *req;
struct Window *w;
static LONG left=-1,top=-1,width=-1,height=-1;
Object *app = (Object *)xget(win,MUIA_ApplicationObject);
char *res = NULL;
static const struct Hook IntuiMsgHook = { { 0,0 },(VOID *)IntuiMsgFunc,NULL,NULL };
get(win,MUIA_Window_Window,&w);
if (left==-1)
{
left = w->LeftEdge+w->BorderLeft+2;
top = w->TopEdge+w->BorderTop+2;
width = w->Width-w->BorderLeft-w->BorderRight-4;
height = w->Height-w->BorderTop-w->BorderBottom-4;
}
if (req=MUI_AllocAslRequestTags(ASL_FileRequest,
ASLFR_Window, w,
ASLFR_TitleText, title,
ASLFR_InitialLeftEdge, left,
ASLFR_InitialTopEdge , top,
ASLFR_InitialWidth , width,
ASLFR_InitialHeight , height,
ASLFR_InitialDrawer , "DITO:Dict",
ASLFR_InitialPattern , "#?.dict",
ASLFR_DoSaveMode , save,
ASLFR_DoPatterns , TRUE,
ASLFR_RejectIcons , TRUE,
ASLFR_UserData , app,
ASLFR_IntuiMsgFunc , &IntuiMsgHook,
TAG_DONE))
{
set(app,MUIA_Application_Sleep,TRUE);
if (MUI_AslRequestTags(req,TAG_DONE))
{
if (*req->fr_File)
{
res = buf;
stccpy(buf,req->fr_Drawer,sizeof(buf));
AddPart(buf,req->fr_File,sizeof(buf));
}
left = req->fr_LeftEdge;
top = req->fr_TopEdge;
width = req->fr_Width;
height = req->fr_Height;
}
MUI_FreeAslRequest(req);
set(app,MUIA_Application_Sleep,FALSE);
}
return(res);
}
///
/// MainWindow_Open
ULONG MainWindow_Open(struct IClass *cl,Object *obj,struct {ULONG MethodID; char *name;} *msg)
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
char *name;
if(msg->name)
{
name = msg->name;
}
else
{
name = getfilename("Select Dictionary",FALSE);
}
if(name)
{
set(obj, MUIA_Window_Open, FALSE);
InitSearch(data);
if(data->dict) DITO_CloseDict(data->dict);
if(data->dict = DITO_OpenDict(name))
{
struct DITO_FileInfo fi;
if(data->output)
{
DoMethod (data->grammar, OM_REMMEMBER, data->output->obj);
MUI_DisposeObject(data->output->obj);
}
DisposeExt(data);
DITO_GetFileInfo(&fi,name);
{
char lib[200];
sprintf(lib, "PROGDIR:Ext/%s.dito", fi.Language);
if(DitoExtBase = OpenLibrary(lib,0))
{
if(data->output = DITO_CreateOutput(app))
{
DoMethod (data->grammar, OM_ADDMEMBER, data->output->obj);
}
else puts("Couldn't open DITO output extension");
}
else puts("ditoext.library");
}
}
set(data->str, MUIA_String_Contents, "");
set(data->grammar, MUIA_Disabled, TRUE);
set(data->grammar, MUIA_ShowMe, TRUE);
set(data->balance, MUIA_ShowMe, TRUE);
set(obj, MUIA_Window_Open, TRUE);
}
return(0);
}
///
/// MainWindow_New
ULONG MainWindow_New(struct IClass *cl,Object *obj,struct opSet *msg)
{
Object *strip;
struct MainWindow_Data tmp = {0};
static const struct Hook DisplayHook = { { NULL,NULL },(VOID *)Display ,NULL,NULL };
if (obj = (Object *)DoSuperNew(cl,obj,
MUIA_Window_Title, NAME " " VERS,
MUIA_Window_ID , MAKE_ID('M','A','I','N'),
MUIA_Window_Menustrip, strip = MUI_MakeObject(MUIO_MenustripNM,MainMenu,0),
WindowContents, VGroup,
Child, HGroup,
Child, tmp.list = ListviewObject,
MUIA_CycleChain, 1,
MUIA_Listview_DoubleClick, TRUE,
MUIA_Listview_Input, TRUE,
MUIA_Listview_List, ListObject,
MUIA_Frame, MUIV_Frame_InputList,
MUIA_List_Format, "miw=50 maw=50 p=\033b, miw=50",
MUIA_List_DisplayHook, &DisplayHook,
End,
End,
Child, tmp.balance = BalanceObject,
MUIA_ShowMe, FALSE,
End,
Child, tmp.grammar = VGroup,
MUIA_ShowMe, FALSE,
End,
End,
Child, tmp.str = StringObject,
MUIA_CycleChain, 1,
MUIA_String_MaxLen, 255,
MUIA_ControlChar, ' ',
MUIA_Frame, MUIV_Frame_String,
MUIA_ShortHelp, "AMIGA + SPACE",
End,
End,
TAG_MORE,msg->ops_AttrList))
{
struct MainWindow_Data *data = INST_DATA(cl,obj);
Object *app = (Object *)xget(obj,MUIA_ApplicationObject);
DoMethod(obj ,MUIM_Notify,MUIA_Window_CloseRequest,TRUE ,obj,1,MUIM_MainWindow_Iconify);
DoMethod(tmp.str, MUIM_Notify, MUIA_String_Acknowledge, MUIV_EveryTime,obj,2,MUIM_MainWindow_Refresh, 0);
DoMethod(tmp.list, MUIM_Notify, MUIA_List_Active, MUIV_EveryTime, obj,1,MUIM_MainWindow_Grammar);
// DoMethod(app, MUIM_Notify, MUIA_Application_ReturnID, 1,obj,1,MUIM_MainWindow_Update);
DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_ABOUT ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,1,MUIM_MainWindow_About);
DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_OPEN ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Open,0);
DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_HIDE ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,1,MUIM_MainWindow_Iconify);
DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_QUIT ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,obj,2,MUIM_MainWindow_Finish,0);
DoMethod((Object *)DoMethod(strip,MUIM_FindUData,MEN_MUI ),MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,MUIV_Notify_Application,2,MUIM_Application_OpenConfigWindow,0);
/*
set(BT_Save ,MUIA_ShortHelp,GetStr(MSG_HELP_SAVE ));
set(BT_Use ,MUIA_ShortHelp,GetStr(MSG_HELP_USE ));
set(BT_Cancel,MUIA_ShortHelp,GetStr(MSG_HELP_CANCEL));
*/
set(obj, MUIA_Window_ActiveObject, tmp.str);
set(obj, MUIA_Window_DefaultObject, tmp.str);
set(tmp.str, MUIA_String_AttachedList, tmp.list);
tmp.db = DITO_CreateDatabase();
tmp.dict = 0;
tmp.DitoExtBaseOO = 0;
tmp.output = 0;
*data = tmp;
return((ULONG)obj);
}
return(0);
}
///
/// MainWindow_Dispatcher
SAVEDS ASM ULONG MainWindow_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
{
switch (msg->MethodID)
{
case OM_NEW : return(MainWindow_New (cl,obj,(APTR)msg));
case MUIM_MainWindow_Finish : return(MainWindow_Finish (cl,obj,(APTR)msg));
case MUIM_MainWindow_Iconify: return(MainWindow_Iconify(cl,obj,(APTR)msg));
case MUIM_MainWindow_About : return(MainWindow_About (cl,obj,(APTR)msg));
case MUIM_MainWindow_Open : return(MainWindow_Open (cl,obj,(APTR)msg));
case MUIM_MainWindow_Refresh: return(MainWindow_Refresh(cl,obj,(APTR)msg));
case MUIM_MainWindow_Grammar: return(MainWindow_Grammar(cl,obj,(APTR)msg));
case MUIM_MainWindow_Update : return(MainWindow_Update (cl,obj,(APTR)msg));
}
return(DoSuperMethodA(cl,obj,msg));
}
///
// ARexx
/// Rexx_Query
SAVEDS ASM LONG Rexx_Query (REG(a1) struct {char *word; } *msg)
{
DoMethod(win, MUIM_MainWindow_Refresh, msg->word);
return(0);
}
///
/// Rexx_File
SAVEDS ASM LONG Rexx_File (REG(a1) struct {char *name; LONG lang; } *msg)
{
DoMethod(win, MUIM_MainWindow_Open, msg->name);
return(0);
}
///
// Init
/// ExitLibs
VOID ExitLibs(VOID)
{
if (IntuitionBase) CloseLibrary(IntuitionBase);
if (GfxBase ) CloseLibrary(GfxBase );
if (AslBase ) CloseLibrary(AslBase );
if (UtilityBase ) CloseLibrary(UtilityBase );
if (MUIMasterBase) CloseLibrary(MUIMasterBase);
if (DitoBase) CloseLibrary(DitoBase);
}
///
/// InitLibs
BOOL InitLibs(VOID)
{
DitoBase = OpenLibrary(DITO_NAME, DITO_VMIN);
MUIMasterBase = OpenLibrary("muimaster.library",11);
UtilityBase = OpenLibrary("utility.library" ,36);
AslBase = OpenLibrary("asl.library" ,36);
GfxBase = OpenLibrary("graphics.library" ,36);
IntuitionBase = OpenLibrary("intuition.library",36);
if (DitoBase && MUIMasterBase && UtilityBase && AslBase && GfxBase && IntuitionBase)
return(TRUE);
ExitLibs();
return(FALSE);
}
///
/// ExitClasses
VOID ExitClasses(VOID)
{
if (CL_MainWindow ) MUI_DeleteCustomClass(CL_MainWindow );
}
///
/// InitClasses
BOOL InitClasses(VOID)
{
CL_MainWindow = MUI_CreateCustomClass(NULL,MUIC_Window ,NULL,sizeof(struct MainWindow_Data ),MainWindow_Dispatcher );
if (CL_MainWindow)
return(TRUE);
ExitClasses();
return(FALSE);
}
///
/// HandleArgs
/*
const char CLITemplate[] = "NAME,LANGUAGE=L/S,DEFAULT=D/S";
const char CLIHelp[] = "\
\n\
Usage: FastDict <name> LANGUAGE DEFAULT\n\
<name> : name of file or language\n\
LANGUAGE : understand <name> as language\n\
";
LONG HandleArgs(Object *mainwin)
{
struct RDArgs *rda,*rdas;
LONG msg = 0;
struct CLIArgs
{
char *Name;
LONG Language;
LONG Default;
} argarray = { 0,0 };
if (rdas = AllocDosObject(DOS_RDARGS,NULL))
{
rdas->RDA_ExtHelp = (char *)CLIHelp;
if (rda = ReadArgs((char *)CLITemplate,(LONG *)&argarray,rdas))
{
if(argarray.Default)
{
DoMethod(mainwin,MUIM_MainWindow_Open,"PROGDIR:Dict/Default.dict");
}
if (argarray.Name)
{
DoMethod(mainwin,MUIM_MainWindow_Open,argarray.Name);
if (argarray.Language)
{
*/
/* if (!desc)
msg = MSG_CLI_SCREENNOTFOUND;
else if (MUIS_OpenPubScreen(desc))
msg = MSG_CLI_SCREENOPENED;
else
msg = MSG_CLI_SCREENOPENFAILED;
*/
/* }
}
FreeArgs(rda);
}
FreeDosObject(DOS_RDARGS,rdas);
}
return(msg);
}
*/
///
// Main
/// Main Program
int main(int argc,char *argv[])
//void __stdargs __main(char *comline)
{
// extern struct WBStartup *_WBenchMsg;
ULONG sigs=0, id;
Object *app;
int res;
int msg=0;
static const struct Hook Rexx_QueryHook = { { NULL,NULL },(VOID *)Rexx_Query ,NULL,NULL };
static const struct Hook Rexx_FileHook = { { NULL,NULL },(VOID *)Rexx_File ,NULL,NULL };
static struct MUI_Command commands[] =
{
{ "search" ,"word/a" , 1 , (void *)&Rexx_QueryHook },
{ "file" ,"name/a,language/s" , 2 , (void *)&Rexx_FileHook },
{ NULL , NULL , NULL , NULL }
};
// InitLocale();
if (InitLibs())
{
DITO_GetUserInfo(&ui);
if (InitClasses())
{
app = ApplicationObject,
MUIA_Application_Title , NAME,
MUIA_Application_Version , "$VER: " NAME" " VERS " " __AMIGADATE__,
MUIA_Application_Copyright , "© Dirk Holtwick, 1996",
MUIA_Application_Author , "Dirk Holtwick",
MUIA_Application_Description, "Fast Dictionary Tool for DITO Databases",
MUIA_Application_Base , "FASTDICT",
MUIA_Application_SingleTask , TRUE,
MUIA_Application_Commands , commands,
MUIA_Application_Window , win = NewObject(CL_MainWindow->mcc_Class,NULL,TAG_DONE),
End;
if (app)
{
/*
if (_WBenchMsg)
msg = 0;
else
msg = HandleArgs(win);
*/
if(argc==2)
{
puts(argv[1]);
DoMethod(win, MUIM_MainWindow_Open, argv[1]);
}
/*
if (!msg)
{
*/
set(win,MUIA_Window_Open,TRUE);
while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs)) != MUIV_Application_ReturnID_Quit)
{
if(id==1) DoMethod(win, MUIM_MainWindow_Update, 0);
if (sigs)
{
sigs = Wait(sigs | SIGBREAKF_CTRL_C | SIGBREAKF_CTRL_E | SIGBREAKF_CTRL_F);
/* quit when receiving break from console */
if (sigs & SIGBREAKF_CTRL_C)
break;
/* update listview whenever a screen was opened/closed */
// if (sigs & SIGBREAKF_CTRL_E)
// DoMethod(win,MUIM_Panel_Update);
/* deiconify & activate on ctrl-f just like the other prefs programs */
if (sigs & SIGBREAKF_CTRL_F)
{
set(app,MUIA_Application_Iconified,FALSE);
set(win,MUIA_Window_Open,TRUE);
}
}
}
// DoMethod(win,MUIM_Panel_CloseWindows);
set(win,MUIA_Window_Open,FALSE);
}
MUI_DisposeObject(app);
// }
// else msg = MSG_CLI_NOAPPLICATION;
ExitClasses();
}
// else msg = MSG_CLI_OUTOFMEMORY;
ExitLibs();
}
// else msg = MSG_CLI_NOMUIMASTER;
if (msg)
{
/* char *str = GetStr(msg);
char *c = strchr(str,'(');
Write(Output(),str,strlen(str));
res = c ? atol(c+1) : RETURN_OK;
*/
res = RETURN_OK;
}
else
res = RETURN_OK;
// ExitLocale();
exit(res);
}
///